import * as React from "react"; import Link from "next/link"; import { getLessonProps, getLessons } from "../../../src/lib/file"; import type { Context } from "../../../src/utils/chapterPageMethods"; import { getCompletedFileProps } from "../../../src/lib/markdown"; type CompletedProps = { nextLessonId: string | undefined; lessonId: string; title: string; description: string; body: any; }; export default function Completed({ nextLessonId, lessonId, title, description, body, }: CompletedProps) { return (

🎉

{title}

{description}

{nextLessonId ? ( Start Lesson {nextLessonId} ) : null}
Share on Twitter
); } export async function getStaticProps(context: Context) { const { params: { lessonId }, } = context; const { isLastLesson, nextLesson } = getLessonProps(lessonId); const { title, description, body } = getCompletedFileProps(lessonId); return { props: { nextLessonId: isLastLesson ? null : nextLesson?.id, lessonId, title, description, body, }, }; } export const getStaticPaths = () => { const lessons = getLessons(); let paths: string[] = []; lessons.map((lesson: { id: number }) => { paths.push(`/lesson/${lesson.id}/completed`); }); return { paths: paths, fallback: false, }; };